#!/usr/bin/env python
# encoding: utf-8
"""
#-------------------------------------------------------------------#
#                   CONFIDENTIAL --- CUSTOM STUDIOS                 #     
#-------------------------------------------------------------------#
#                                                                   #
#                   @Project Name : Globallawonline                #
#                                                                   #
#                   @File Name    : changeflbsortE.py                      #
#                                                                   #
#                   @Programmer   : 李建                            #
#                                                                   #  
#                   @Start Date   : 2021/8/16 17:44                 #
#                                                                   #
#                   @Last Update  : 2021/8/16 17:44                 #
#                                                                   #
#-------------------------------------------------------------------#
# Classes:修改菲律宾的效力级别信息数据                                                          #
#                                                                   #
#-------------------------------------------------------------------#
"""
import pymysql

from Seetings import JGMYSQL_CONNEXT, CJMYSQL_CONNECT

cj_conn = pymysql.connect(host=CJMYSQL_CONNECT["MYSQL_HOST"],
                          port=CJMYSQL_CONNECT["MYSQL_PORT"],
                          db=CJMYSQL_CONNECT["MYSQL_DB"],
                          user=CJMYSQL_CONNECT["MYSQL_USER"],
                          passwd=CJMYSQL_CONNECT["MYSQL_PASSWD"],
                          charset=CJMYSQL_CONNECT["MYSQL_CHARSET"])
jg_conn = pymysql.connect(host=JGMYSQL_CONNEXT["MYSQL_HOST"],
                          port=JGMYSQL_CONNEXT["MYSQL_PORT"],
                          db=JGMYSQL_CONNEXT["MYSQL_DB"],
                          user=JGMYSQL_CONNEXT["MYSQL_USER"],
                          passwd=JGMYSQL_CONNEXT["MYSQL_PASSWD"],
                          charset=JGMYSQL_CONNEXT["MYSQL_CHARSET"])

cjsql = '''SELECT SYSID,SORTE FROM lawtext WHERE SortA = "LAWCOUNTRYFLB"'''
try:
    with cj_conn.cursor() as cj_cursor:
        cj_cursor.execute(cjsql)
        datas = cj_cursor.fetchall()
except Exception as e:
    print("采集服务器查询出错:%s(%s)" % (str(e), cjsql))
for data in datas:
    sysid = data[0]
    sortE = data[1]
    jgsql = '''update `law` set SORTE = "%s" where SYSID = "%s"''' % (sortE,sysid)
    try:
        with jg_conn.cursor() as jg_cursor:
            jg_cursor.execute(jgsql)
            jg_conn.commit()
    except Exception as e:
        print("加工服务器查询出错:%s(%s)" % (str(e), jgsql))
cj_conn.close()
jg_conn.close()
